<div class="pageContent">
	
	<form method="post" action="/index.php?act=news&st=newsEdit" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
		<input type="hidden" name="id" value="{$info.id}" />
		<div class="pageFormContent" layoutH="58">

			<div class="unit">
				<label>标题：</label>
				<input type="text" name="title" maxlength="30" class="required" errormsg="请输入标题" value="{$info.title}"/>
			</div>
			<div class="unit">
				<label>作者：</label>
				<input type="text" name="author" class="required" errormsg="请输入您的姓名" value="{if $info.author}{$info.author}{else}{$session.admin.username}{/if}"/>
			</div>
			<div class="unit">
				<label>所属栏目：</label>
				<select class="combox" name="category_id" ref="category_parent_edit_id" refUrl="/index.php?act=news&st=get_category&id={value}">
					{foreach item=item key=key from=$topic}
					<option value="{$item.category_id}" {if $item.category_id eq $info.category_parent_id || $item.category_id eq $info.category_id}selected{/if}>{$item.category_name}</option>
					{/foreach}
				</select>
				<select class="combox" name="category_parent_id" id="category_parent_edit_id">
					{foreach item=item key=key from=$child}
					<option value="{$item.category_id}" {if $item.category_id eq $info.category_id}selected{/if}>{$item.category_name}</option>
					{/foreach}
				</select>
			</div>
			<div class="unit">
				<label>摘要：</label>
				<textarea name="digest" cols="40" rows="5">{$info.digest}</textarea>
			</div>
			<div class="unit">
				<label>排序：</label>
				<input type="text" name="article_index" class="digits required" errormsg="请输入排序(整数)" value="{if $info.article_index}{$info.article_index}{else}1{/if}"/>
				<span class="info">&nbsp;&nbsp;数字越大越靠前</span>
			</div>
			<div class="unit">
				<label>图文消息地址：</label>
				<input type="text" name="content_source_url" class="url" errormsg="请输入合法网址" value="{$info.content_source_url}"/>
			</div>
			<div class="unit">
				<dl>
					<label>封面图片：</label>
					<dd>
						<input type="file" id="uploadify" class="input-xlarge" name="uploadify">	
						<input type="hidden" id="ad_img_path" name="ad_img_path" class="required" value="{$info.picurl}" errormsg="请选择上传的图片">
					</dd>
				</dl>
			</div>
			<br/><br/>
			<div class="unit" id="image_play" {if !$info.picurl}style="display:none"{/if}>
			<br/><br/>
				<dl>
					<label>图片预览：</label>
					<dd>
						<div style="width:460px;height:200px;float:left;margin-left:10px;">
						<div style="width:360px;height:200px;float:left;">
						<img style="width:100%;height:100%" src="{if $info.picurl}{$info.picurl}{else}/files/images/not-set.jpg{/if}">
						</div>&nbsp;
						<span id="delbutton"  style="cursor: pointer; color: red; margin-left: 2px; width: 50px; float: left;" alt="删除" title="删除">[ 删除 ]</span>
						</div>
					</dd>
				</dl>
				<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
			</div>
			<div class="unit">
				<dl>
					<label>微信端可见用户：</label>
					<dd>
						<table border="1" width="600px" style="padding:0 0 0 0;margin:0 0 0 0;">		
							<tbody>
								{foreach item=items from=$category}
								<tr width="100%" style="padding:0 0 0 0;margin:0 0 0 0;">						
									<td>
										<label>
											<input type="checkbox" group="category_{$items.user_category_id}[]" class="checkboxCtrl" {if in_array($items.user_category_id,$info.visibleparents)}checked{/if}/>{$items.category_name}
											<input type="hidden" name="parent_id[]" value="{$items.user_category_id}">
										</label>
									</td>
									<td>
									{foreach item=child from=$items.child}
										<label>
											<input type="checkbox" name="category_{$items.user_category_id}[]" value="{$child.user_category_id}" {if ($info.visible and in_array($child.user_category_id,$info.visible))}checked{/if} />{$child.category_name}
										</label>
									{/foreach}
									</td>
								</tr>
								{/foreach}
							</tbody>
						</table>
					</dd>
				</dl>
				<br/><br/><br/><br/><br/><br/><br/><br/><br/>
			</div>
			<div class="unit">
				<dl>
					<label>新闻内容：</label>
					<dd>
							<textarea class="editor" name="content" rows="25" cols="100"
							upLinkUrl="/index.php?act=editor&st=fileUp" upLinkExt="zip,rar,txt" 
							upImgUrl="/index.php?act=editor&st=imageUp" upImgExt="jpg,jpeg,gif,png" 
							upFlashUrl="/index.php?act=editor&st=fileUp" upFlashExt="swf"
							upMediaUrl="/index.php?act=editor&st=fileUp" upMediaExt:"avi" errormsg="请输入新闻内容">{$info.content}</textarea>
					</dd>
				</dl>				
			</div>

		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">提交</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
			</ul>
		</div>
	</form>
	
</div>
<script type="text/javascript">
var no_set = '/files/images/not-set.jpg';
$(function() {
    $('#uploadify').uploadify({
        'buttonText'      	: '上传封面图片',
        'swf'      			: '{$host}/files/js/uploadify/uploadify.swf',
        'uploader' 			: '{$host}/index.php?act=news&st=imageUplody',
        'cancelImg'			: '{$host}/files/js/uploadify/uploadify-cancel.png',
        'auto' 				: true,
        'onUploadSuccess' 	: function(file, data, response) {
            var ad_img = $('#ad_img_path').val();
            var data = eval('('+data+')');

            if(data['state'] == 'SUCCESS'){
				$("#image_play img").attr("src",data['url']);
                $("#ad_img_path").val(data['url']);
				$("#image_play").show();
				delImage();
            }else{
                alert(data['state']);
                return false;
            }
        }
    });
	delImage();
});
function delImage(){
    $("#delbutton").click(function(){
        $("#image_play img").attr("src",no_set);
		$("#ad_img_path").val('');
		$("#image_play").hide();
    })
}
</script>